import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * user:likai
 * Date:2023-01-12
 * Time:18:18
 */
class MyQueue {
    Stack<Integer> stack1;
    Stack<Integer> stack2;
    public MyQueue() {
        stack1=new Stack<>();
        stack2=new Stack<>();
    }

    public void push(int x) {
        stack1.push(x);
    }
    public int pop() {
        if(stack2.isEmpty()){
            if(stack1.isEmpty()){
                return -1;
            }
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }

    public int peek() {
        if(stack2.isEmpty()){
            if(stack1.isEmpty()){
                return -1;
            }
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.peek();
    }

    public boolean empty() {
        if(stack1.isEmpty()&&stack2.isEmpty()){
            return true;
        }
        return false;
    }
}
class MyCircularQueue {
    public int []elem;
    public int front;
    public int tail;

    public MyCircularQueue(int k) {
        elem=new int[k+1];
    }
    public boolean enQueue(int value) {
        if(isFull()){
            return false;
        }else{
            elem[tail]=value;
            tail=(tail+1)%elem.length;
            return true;
        }
    }

    public boolean deQueue() {
        if(isEmpty()){
            return false;
        }else{
            front=(front+1)%elem.length;
            return true;
        }
    }

    public int Front() {
        if(isEmpty()){
            return -1;
        }else{
            return elem[front];
        }
    }

    public int Rear() {
        if(isEmpty()){
            return-1;
        }else{
            if(tail==0){
                return elem[elem.length-1];
            }else{
                return elem[tail-1];
            }
        }
    }

    public boolean isEmpty() {
        if(front==tail){
            return true;
        }else{
            return false;
        }
    }

    public boolean isFull() {
        if((tail+1)%elem.length==front){
            return true;
        }
        return false;
    }
}
public class Test {
}
